package com.tszs.Controller;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.tszs.biz.AdministratorTableBiz;
import com.tszs.biz.CategoryManagementBiz;
import com.tszs.biz.HomeRotaryMapBiz;
import com.tszs.biz.SmsConfigurationBiz;
import com.tszs.dao.mapper.CategoryManagementMapper;
import com.tszs.dao.mapper.CommodityListMapper;
import com.tszs.entity.AdministratorTable;
import com.tszs.entity.AdministratorTableExample;
import com.tszs.entity.AdministratorTableExample.Criteria;
import com.tszs.entity.CategoryManagement;
import com.tszs.entity.HomeRotaryMap;
import com.tszs.entity.SmsConfiguration;
/**
 * @类名:UrlContorller
 * @类描述:页面跳转
 * @创建人:王俊
 * @创建时间:2019-03-21 14:04:41
 *
 */
@Controller
public class UrlContorller {
	@Autowired
	private AdministratorTableBiz administratorTableBiz;
	
	@Autowired
	private CommodityListMapper commodityListMapper;
	
	@Autowired
	private CategoryManagementBiz categoryManageBiz;
	
	@Autowired
	private CategoryManagementMapper categoryMapper;
	
	@Autowired
	private HomeRotaryMapBiz homeRotaryMapBiz;
	
	@Autowired
	private SmsConfigurationBiz smsConfigurationBiz;
	
	@RequestMapping("pc/admin/index")
	public String index() {
		return "WEB-INF/pc/admin/index";
	}
	/**
	 * @类名:AddedAdministrator
	 * @类描述:管理员查询
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 *
	 */
	@RequestMapping("pc/admin/AddedAdministrator")
	public String AddedAdministrator() {
		return "WEB-INF/pc/admin/managementAdd";
	}
	/**
	 * @类名:managementAdd
	 * @类描述:管理员添加
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 *
	 */
	@RequestMapping("pc/admin/managementAdd")
	public String managementAdd(HttpServletRequest request) {
			return "WEB-INF/pc/admin/managementAdd";
	}
	/**
	 * @类名:AdministratorManagement
	 * @类描述:管理员查看
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 *
	 */

	@RequestMapping("pc/admin/AdministratorManagement")
	public String AdministratorManagement() {
		return "WEB-INF/pc/admin/AddedAdministrator";
	}
	/**
	 * @类名:viewPermission
	 * @类描述:个人权限查询
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 *
	 */
	@RequestMapping("pc/admin/viewPermission")
	public String viewPermission(HttpServletRequest request) {
		request.setAttribute("id", request.getParameter("id"));
		return "WEB-INF/pc/admin/viewPermission";
	}
	/**
	 * 修改权限
	 * @author Fujing
	 * @date 2019年5月28日 下午1:43:34
	 * @param request
	 * @return String
	 */
	@RequestMapping("pc/admin/updateAuth")
	public String updateAuth(HttpServletRequest request) {
		request.setAttribute("id", request.getParameter("id"));
		return "WEB-INF/pc/admin/updateAuth";
	}
	/**
	 * @类名:viewPermission
	 * @类描述:密码修改
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 *
	 */
	@RequestMapping("pc/admin/managementUpdate")
	public String managementUpdate(HttpServletRequest request) {
		String id=request.getParameter("id");
		AdministratorTableExample example=new AdministratorTableExample();
		Criteria ca=example.createCriteria();
		ca.andAIdEqualTo(id);
		List<AdministratorTable> selectByExamplePage=administratorTableBiz.selectByExample(example);
		if(!selectByExamplePage.isEmpty()) {
			request.setAttribute("id", id);
			request.setAttribute("aUsername", selectByExamplePage.get(0).getaUsername());
		}
		return "WEB-INF/pc/admin/managementUpdate";
	}
	/**
	 * @类名:managementUpdate
	 * @类描述:個人密码修改
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 *
	 */
	@RequestMapping("pc/admin/ChangePassword")
	public String ChangePassword(HttpServletRequest request) {
		request.setAttribute("aUsername",request.getSession().getAttribute("aUsername"));
		return "WEB-INF/pc/admin/managementUpdate";
	}
	/**
	 * @类名:subclassManagement
	 * @类描述:子类页面跳转
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 *
	 */
	@RequestMapping("pc/admin/subclassManagement")
	public String subclassManagement(HttpServletRequest request) {
		return "WEB-INF/pc/admin/subclassManagement";
	}
	/**
	 * @类名:SmallClassManagement
	 * @类描述:小类页面跳转
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 *
	 */
	@RequestMapping("pc/admin/SmallClassManagement")
	public String SmallClassManagement(HttpServletRequest request) {
		
		CategoryManagement record = new CategoryManagement();
		record.setcType("1");
		request.setAttribute("list", categoryManageBiz.selectByType(record));
		
		return "WEB-INF/pc/admin/SmallClassManagement";
	}
	/**
	 * @类名:largeClassManagement
	 * @类描述:大类页面跳转
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/largeClassManagement")
	public String largeClassManagement(HttpServletRequest request) {
		return "WEB-INF/pc/admin/largeClassManagement";
	}
	/**
	 * @类名:updateCateGory
	 * @类描述:大类修改页面跳转
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 * @throws UnsupportedEncodingException 
	 *
	 */
	@RequestMapping("pc/admin/updateCateGory")
	public String updateCateGory(HttpServletRequest request) throws UnsupportedEncodingException {
		
		String id = request.getParameter("id");
		CategoryManagement cate =  categoryMapper.findById(id);
		
		request.setAttribute("id", cate.getcId());
		request.setAttribute("names", cate.getcName());
		request.setAttribute("photo", cate.getcPhoto());
		return "WEB-INF/pc/admin/updateCateGory";
	}	
	/**
	 * @类名:memberOrder
	 * @类描述:会员订单页面跳转
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 * @throws UnsupportedEncodingException 
	 *
	 */
	@RequestMapping("pc/admin/memberOrder")
	public String memberOrder(HttpServletRequest request) throws UnsupportedEncodingException {
		return "WEB-INF/pc/admin/memberOrder";
	}
	/**
	 * @类名:officialWebsiteGoods
	 * @类描述:官网商品跳转
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 * @throws UnsupportedEncodingException 
	 *
	 */
	@RequestMapping("pc/admin/officialWebsiteGoods")
	public String officialWebsiteGoods(HttpServletRequest request) throws UnsupportedEncodingException {
		return "WEB-INF/pc/admin/officialWebsiteGoods";
	}
	/**
	 * @类名:commodityAddition
	 * @类描述:官网添加
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 * @throws UnsupportedEncodingException 
	 *
	 */
	@RequestMapping("pc/admin/commodityAddition")
	public String commodityAddition(HttpServletRequest request) throws UnsupportedEncodingException {
		
		CategoryManagement cate = new CategoryManagement();
		cate.setcType("2");
		
		String id =  (String)request.getParameter("id");
		
		if (!"".equals(id)) {
			request.getSession().setAttribute("obj",commodityListMapper.findById(id));
		}
		request.getSession().setAttribute("cateList", categoryManageBiz.findCateType(cate));
		return "WEB-INF/pc/admin/commodityAddition";
	}
	/**
	 * @类名:unauditedCommodities
	 * @类描述:未审核商品跳转
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 * @throws UnsupportedEncodingException 
	 *
	 */
	@RequestMapping("pc/admin/unauditedCommodities")
	public String unauditedCommodities(HttpServletRequest request) throws UnsupportedEncodingException {
		//放入类别查找的选项
		CategoryManagement cate = new CategoryManagement();
		cate.setcType("1");
		//TODO
		request.getSession().setAttribute("cateList", categoryManageBiz.findCateType(cate));
		
		return "WEB-INF/pc/admin/unauditedCommodities";
	}
	/**
	 * @类名:platformWideCommodities
	 * @类描述:全平台商品
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 * @throws UnsupportedEncodingException 
	 *
	 */
	@RequestMapping("pc/admin/platformWideCommodities")
	public String platformWideCommodities(HttpServletRequest request) throws UnsupportedEncodingException {
		//放入类别查找的选项
		CategoryManagement cate = new CategoryManagement();
		cate.setcType("1");
		//TODO
		request.getSession().setAttribute("cateList", categoryManageBiz.findCateType(cate));
		return "WEB-INF/pc/admin/platformWideCommodities";
	}
	/**
	 * @类名:platformWideCommodities
	 * @类描述:订单报表跳转
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 * @throws UnsupportedEncodingException 
	 *
	 */
	@RequestMapping("pc/admin/orderReport")
	public String orderReport(HttpServletRequest request) throws UnsupportedEncodingException {
		return "WEB-INF/pc/admin/orderReport";
	}
	/**
	 * @类名:offlinePayment
	 * @类描述:线下支付跳转
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 * @throws UnsupportedEncodingException 
	 *
	 */
	@RequestMapping("pc/admin/offlinePayment")
	public String offlinePayment(HttpServletRequest request) throws UnsupportedEncodingException {
		return "WEB-INF/pc/admin/offlinePayment";
	}
	/**
	 * @类名:offlinePayment
	 * @类描述:提现管理跳转
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 * @throws UnsupportedEncodingException 
	 *
	 */
	@RequestMapping("pc/admin/cashManagement")
	public String cashManagement(HttpServletRequest request) throws UnsupportedEncodingException {
		return "WEB-INF/pc/admin/cashManagement";
	}
	/**
	 * @类名:financialDetails
	 * @类描述:商家账户管理
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/financialDetails")
	public String financialDetails(HttpServletRequest request) throws UnsupportedEncodingException {
		return "WEB-INF/pc/admin/financialDetails";
	}
	/**
	 * @类名:orderDetails
	 * @类描述:订单详情页面跳转
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/orderDetails")
	public String orderDetails(HttpServletRequest request) throws UnsupportedEncodingException {
		try {
			request.setAttribute("type", request.getParameter("type"));
			request.setAttribute("id", request.getParameter("id"));
			return "WEB-INF/pc/admin/orderDetails";
		} catch (Exception e) {
			return "WEB-INF/pc/admin/orderDetails";
		}
	}
	/**
	 * @类名:orderDetails
	 * @类描述:提现管理详情页面跳转
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/detailsOfWithdrawals")
	public String detailsOfWithdrawals(HttpServletRequest request) throws UnsupportedEncodingException {
		try {
			request.setAttribute("id", request.getParameter("id"));
			request.setAttribute("type", request.getParameter("type"));
			return "WEB-INF/pc/admin/detailsOfWithdrawals";
		} catch (Exception e) {
			return "WEB-INF/pc/admin/detailsOfWithdrawals";
		}
	}
	/**
	 * @类名:distributionAllocation
	 * @类描述:分销配置页面跳转
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/distributionAllocation")
	public String distributionAllocation(HttpServletRequest request) throws UnsupportedEncodingException {
			return "WEB-INF/pc/admin/distributionAllocation";
	}
	/**
	 * @类名:detailedFinancialAmount
	 * @类描述:财务明细跳转页面
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/detailedFinancialAmount")
	public String detailedFinancialAmount(HttpServletRequest request) throws UnsupportedEncodingException {
			return "WEB-INF/pc/admin/detailedFinancialAmount";
	}
	/**
	 * @类名:detailedFinancialAmount
	 * @类描述:分销查询
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/distributionDetailsTable")
	public String distributionDetailsTable(HttpServletRequest request) throws UnsupportedEncodingException {
			return "WEB-INF/pc/admin/distributionDetailsTable";
	}
	/**
	 * @类名:homeRotaryMap
	 * @类描述:首页轮播图
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/homeRotaryMap")
	public String homeRotaryMap(HttpServletRequest request) throws UnsupportedEncodingException {
		HomeRotaryMap example = new HomeRotaryMap();
		
		List<HomeRotaryMap> selectByExample = homeRotaryMapBiz.selectByExamplePage(example);
		request.getSession().setAttribute("list", selectByExample.get(0).gethPhoto());
		//TODO
		return "WEB-INF/pc/admin/homeRotaryMap";
	}
	
	/**
	 * 在线客服
	 * @author Fujing
	 * @date 2019年5月31日 下午3:52:39
	 * @param request
	 * @return String
	 */
	@RequestMapping("pc/admin/onlineService")
	public String onlineService(HttpServletRequest request) {
		
		String value = "在线客服";
		
		SmsConfiguration sms = smsConfigurationBiz.queryOnlineService(value);
		request.setAttribute("id", sms == null ? "":sms.getsId());
		request.setAttribute("sConten", sms == null ? "":sms.getsConten());
		return "WEB-INF/pc/admin/onlineService";
	}
	
	
	/***
	 * 权限管理页面 权限内容修改
	 * @author MRC
	 * @date 2019年6月1日上午10:24:10
	 * @param request
	 * @return
	 */
	@RequestMapping("pc/admin/authorityManage")
	public String authorityManage(HttpServletRequest request) {
		
		return "WEB-INF/pc/admin/authorityManage";
	}
	
	/***
	 * 修改线下支付银行信息
	 * @author MRC
	 * @date 2019年6月1日上午10:24:10
	 * @param request
	 * @return
	 */
	@RequestMapping("pc/admin/saveBankInfo")
	public String saveBankInfo(HttpServletRequest request) {
		
		
		SmsConfiguration sms = smsConfigurationBiz.queryOnlineService("bankAccount");
		SmsConfiguration openBankName = smsConfigurationBiz.queryOnlineService("openBankName");
		SmsConfiguration bankName = smsConfigurationBiz.queryOnlineService("bankName");
		SmsConfiguration bankAddress = smsConfigurationBiz.queryOnlineService("bankAddress");
		//TODO
		request.setAttribute("bankAccount", sms == null?"":sms.getsConten());
		request.setAttribute("openBankName", openBankName == null?"":openBankName.getsConten());
		request.setAttribute("bankName", bankName == null?"":bankName.getsConten());
		request.setAttribute("bankAddress", bankAddress == null?"":bankAddress.getsConten());
		
		return "WEB-INF/pc/admin/saveBankInfo";
	}
	
	
	/**
	 * @类名:friendlyLinks
	 * @类描述:友情链接
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/friendlyLinks")
	public String friendlyLinks(HttpServletRequest request) throws UnsupportedEncodingException {
		try {
			request.setAttribute("id", request.getParameter("id"));
			request.setAttribute("type", request.getParameter("type"));
			return "WEB-INF/pc/admin/friendlyLinks";
		} catch (Exception e) {
			return "WEB-INF/pc/admin/friendlyLinks";
		}
	}
	/**
	 * @类名:friendlyLinks
	 * @类描述:友情链接分页
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/friendshipLinkPaging")
	public String friendshipLinkPaging(HttpServletRequest request) throws UnsupportedEncodingException {
			return "WEB-INF/pc/admin/friendshipLinkPaging";
	}
	/**
	 * @类名:messageManagement
	 * @类描述:留言管理
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/messageManagement")
	public String messageManagement(HttpServletRequest request) throws UnsupportedEncodingException {
			return "WEB-INF/pc/admin/messageManagement";
	}
	/**
	 * @类名:Feedback
	 * @类描述:留言管理
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/Feedback")
	public String Feedback(HttpServletRequest request) throws UnsupportedEncodingException {
			return "WEB-INF/pc/admin/Feedback";
	}
	/**
	 * @类名:Feedback
	 * @类描述:反馈回复
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/FeedbackRecovery")
	public String FeedbackRecovery(HttpServletRequest request) throws UnsupportedEncodingException {
		try {
			request.setAttribute("id", request.getParameter("id"));
			request.setAttribute("type", request.getParameter("type"));
			return "WEB-INF/pc/admin/FeedbackRecovery";
		} catch (Exception e) {
			return "WEB-INF/pc/admin/FeedbackRecovery";
		}
	}
	/**
	 * @类名:SMSConfiguration
	 * @类描述:短信配置
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/SMSConfiguration")
	public String SMSConfiguration(HttpServletRequest request) throws UnsupportedEncodingException {
		try {
			request.setAttribute("id", request.getParameter("id"));
			request.setAttribute("type", request.getParameter("type"));
			return "WEB-INF/pc/admin/SMSConfiguration";
		} catch (Exception e) {
			return "WEB-INF/pc/admin/SMSConfiguration";
		}
	}
	/**
	 * @类名:综合统计
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/comprehensiveStatistics")
	public String comprehensiveStatistics(HttpServletRequest request) throws UnsupportedEncodingException {
			return "WEB-INF/pc/admin/comprehensiveStatistics";
	}
	/**
	 * @类名:recentVisit
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/recentVisit")
	public String recentVisit(HttpServletRequest request) throws UnsupportedEncodingException {
			return "WEB-INF/pc/admin/recentVisit";
	}
	/**
	 * @类名:recentVisit
	 * @类描述:日志
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/buyCar")
	public String buyCar(HttpServletRequest request) throws UnsupportedEncodingException {
			return "WEB-INF/pc/admin/buyCar";
	}
	/**
	 * @类名:付款
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/pay/Alipay/goPay")
	public String goPay(HttpServletRequest request) throws UnsupportedEncodingException {
	
			return "WEB-INF/pc/pay/Alipay/goPay";
	}
	
	/**
	 * @类名:退款
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/pay/Alipay/refund")
	public String refund(HttpServletRequest request) throws UnsupportedEncodingException {
			return "WEB-INF/pc/pay/Alipay/refund";
	}
	/**
	 * @类名:电脑网站支付return_url
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/pay/return_url")
	public String return_url(HttpServletRequest request) throws UnsupportedEncodingException {
			return "WEB-INF/pc/pay/Alipay/return_url";
	}
	
	/**
	 * @类名:付宝服务器异步通知页面
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/pay/Alipay/notify_url")
	public String notify_url(HttpServletRequest request) throws UnsupportedEncodingException {
			return "WEB-INF/pc/pay/Alipay/notify_url";
	}
	/**
	 * @类名:distributionApproval
	 * @类描述:分销审批
	 * @创建人:王俊
	 * @创建时间:2019-03-21 14:04:41
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/distributionApproval")
	public String distributionApproval(HttpServletRequest request) throws UnsupportedEncodingException {
		return "WEB-INF/pc/admin/distributionApproval";
	}
}
